package com.blog.applet.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.blog.applet.common.core.controller.BaseController;
import com.blog.applet.common.core.domain.AjaxResult;
import com.blog.applet.common.core.domain.PageResult;
import com.blog.applet.domain.BlogCategories;
import com.blog.applet.service.BlogCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/***
 * @Author 鳄鱼杆
 * @Date 2025/5/21 20:29
 */
@RestController
@RequestMapping("/category")
public class BlogCategoryController extends BaseController {

    @Autowired
    private BlogCategoryService blogCategoryService;

    /**
     * 分页查询分类列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/listPage")
    public AjaxResult listCategory(Integer pageNum, Integer pageSize){

        IPage<BlogCategories> page =  blogCategoryService.selectPage(pageNum,pageSize);

        return getPageData(page);
    }


    /**
     * 查询所有分类
     * @return AjaxResult
     */
    @GetMapping("/list")
    public AjaxResult list(){
        return success(blogCategoryService.list());
    }

}
